﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace VariousEncodings
{
    class VarEncodings
    {
        public static string ChangeEncodingFromUTF16(Encoding enc, string s)
        {
            byte[] bytes = enc.GetBytes(s);
            StringBuilder sb = new StringBuilder();
            foreach (var bt in bytes)
            {
                sb.Append(string.Format("\\x{0:X}", bt));
            }
            return sb.ToString();
        }

        static void Main()
        {
            string input = "汉语/漢語";
            Console.WriteLine(ChangeEncodingFromUTF16(Encoding.ASCII, input));
            Console.WriteLine(ChangeEncodingFromUTF16(Encoding.UTF8, input));
            Console.WriteLine(ChangeEncodingFromUTF16(Encoding.BigEndianUnicode, input));
            Console.WriteLine(ChangeEncodingFromUTF16(Encoding.GetEncoding("windows-1251"), input));
        }
    }
}
